/**
 * 项目名称:
 *
 * @Author: 夏国倩
 * @Date: 2023/10/10 15:49
 * @Copyright
 */
package IO2;

import java.io.FileReader;
import java.io.FileWriter;

/*
文件复制
只能复制纯文本文件
D:\Files\a-LocalRepository\IODemo\src\HelloWorld.java
 */
public class Copy2 {
    public static void main(String[] args) throws Exception{
        //读
        FileReader in=new FileReader("");
        //写
        FileWriter out=new FileWriter("");

        //一边读一边写
        char[] chars=new char[1024*512]; //1MB
        int readCount=0;
        while ((readCount = in.read(chars)) !=-1){
            out.write(chars,0,readCount);
        }
        //刷新
        out.flush();
        //关闭
        if (in!=null){
            in.close();
        }
        if (out!=null){
            out.close();
        }
    }
}
